<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 100px;
            height: 100px;
            background-color: grey;
            user-select: none;
            border-bottom:black solid 1px;
        }
    </style>
</head>
<body>
    <div>1</div>
    <div>2</div>
    <div>3</div>
</body>
<script>
    let divs = document.querySelectorAll('div');
    //传统方式
    divs[0].onclick = function(){
        alert(11);
        this.onclick = null;
    }
    //新方法
    function fn(){
        alert(22);
        divs[1].removeEventListener('click',fn);
    }
    divs[1].addEventListener('click',fn);
</script>
</html>